package com.rizzo.analytics.domain;

public enum KeyType {

    ALL("all"),
    PERFORMANCE("performance"),
    CACHE("cache"),
    QUOTA("quota"),
    NOTIFICATION("notification"),
    ERROR("error"),
    LOCK("lock");

    private String prefix;

    KeyType(String prefix) {
        this.prefix = prefix;
    }

    public String getPrefix() {
        return prefix;
    }

    public static KeyType fromPrefix(String token) {
        for (KeyType c : KeyType.values()) {
            if (c.prefix.equals(token)) {
                return c;
            }
        }
        throw new IllegalArgumentException("'" + token + "' could not be converted to a KeyType!");
    }

}
